<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品游戏后台管理</title>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <style>
        th{
            text-align: center;
            vertical-align: middle!important;
        }
    </style>
</head>
<body>
{include file="base/header" /}
<br/>

<table class="table table-bordered" style="width: 1300px;margin: 0 auto">
    <tr>
        <th>编号</th>
        <th>商品名称</th>
        <th>商家联系人</th>
        <th>商家电话</th>
        <th>购买数量(个)</th>
        <th>进价(元)</th>
        <th>售价(元)</th>
        <th>总价(元)</th>
        <th>实际总价(元)</th>
        <th>下单日期</th>
        <th>订单号</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    {foreach $result as $val}
    <tr id="del{$val.id}" style="text-align: center">
        <td>{$val.id}</td>
        <td>{$val.pname}</td>
        <td>{$val.linkman}</td>
        <td>{$val.telephone}</td>
        <td>{$val.number}</td>
        <td>{$val.purchaseprice}</td>
        <td>{$val.retailprice}</td>
        <td>{$val.total}</td>
        <td>{$val.actualtotal}</td>
        <td>{$val.date}</td>
        <td>{$val.ordernumber}</td>
        <td>{if $val.status == 1} 购买申请中 {elseif $val.status == 2 /} 购买通过  {elseif $val.status == 3 /} 邮寄中 {elseif $val.status == 4 /}货已到 {elseif $val.status==5/} 已完成 {/if}</td>
        <td>
            <button onclick="del({$val.id})" type="button" class="btn btn-danger btn-xs">删除</button>
            <button onclick="orderDetail({$bid},{$val.id})" type="button" class="btn btn-primary btn-xs" >订单详情</button>
            {if $val.status == 2}
                <button onclick="money({$val.id})" type="button" class="btn btn-warning btn-xs" >打款</button>
            {else /}
                <button disabled type="button" class="btn btn-warning btn-xs" >打款</button>
            {/if}
        </td>
    </tr>
    {/foreach}
</table>
<div style="margin-left: 30px">{$result->render()}</div>
<br/>
</body>
<script>
    //删除
    function del(id) {
        layer.confirm('你确定要删除吗',{bnt:['确定','取消']},
            function () {
                $.ajax({
                    url:"{:url('index/settlement/del')}",
                    type:"post",
                    data:"id="+id,
                    dataType:"json",
                    success:function (data) {
                        if(data.success){
                            layer.alert(data.success);
                            $("#del"+id).remove();
                        }
                        if(data.error){
                            layer.alert(data.error);
                        }
                    }
                });
            }
        );
    }
    //打款
    function money(id) {
        layer.open({
            title:'上传支付凭证',
            anim: 2,
            type: 2,
            content: "{:url('index/settlement/image')}?id="+id,
            area: ['320px', '195px']
            //maxmin: true
        });
    }
    //订单详情
    function orderDetail(bid,id){
        window.location.href = "{:url('index/settlement/orderDetail')}?id="+id+"&bid="+bid;
    }
</script>
</html>